//引入request，提前封装好的axios函数实例对象
import { request } from '@/utils/http';
import {
  IhospitalSetsRes,
  IaddHospitalSetParams,
} from './model/hospitalSetTypes';
import { Key } from 'react';

//获取医院设置表格数据的函数
export const reqGetHospitalSets = (
  page: number, //第几页
  limit: number, //一页多少条
  hosname?: string, //医院名称
  hoscode?: string //医院编码
) => {
  /* return request.get(
    `/admin/hosp/hospitalSet/${page}/${limit}?hosname=${hosname}&hoscode=${hoscode}`
  ); */
  return request.get<any, IhospitalSetsRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname: hosname,
        hoscode: hoscode,
      },
    }
  );
};

//获取添加医院设置的函数
export const reqAddHospitalSet = (data: IaddHospitalSetParams) => {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data);
};

//修改医院设置的函数
export const reqEditHospitalSet = (data: IaddHospitalSetParams) => {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data);
};

//删除一条医院数据的函数
export const reqDelHospitalSet = (id: string) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
};

//批量删除医院的数据
export const reqAllDelHospitalSet = (ids: Key[]) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  });
};
